package com.itc.dispatch.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itc.common.core.domain.R;
import com.itc.common.core.validate.Update;
import com.itc.dispatch.domain.AlarmCentre;
import com.itc.dispatch.domain.AlarmOperatingRecord;
import com.itc.dispatch.domain.dto.*;
import com.itc.dispatch.domain.vo.StatusStatesVo;
import com.itc.dispatch.domain.vo.TypeStatesVo;
import com.itc.dispatch.service.AlarmCentreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/alarm/centre")
@Api(value = "alarmCentre", tags = "告警中心管理模块")
public class AlarmCentreController {

    @Autowired
    private AlarmCentreService alarmCentreService;

    /**
     * 获取告警中心界面分页信息
     * @param
     * @return
     */
    @PostMapping("/page")
    @ApiOperation(value = "获取告警中心界面分页信息")
    public R<Page<AlarmCentre>>getPage(@RequestBody AlarmCentrePageDto pageDto){
        Page page = new Page();
        page.setCurrent(pageDto.getCurrent());
        page.setSize(pageDto.getSize());
        page.setSearchCount(true);
        return alarmCentreService.getPage(page,pageDto);
    }

    /**
     * 确认/处置/误报 告警中心消息
     * @param
     * @return
     */
    @PostMapping("/operation")
    @ApiOperation(value = "确认/处置/误报告警中心消息")
    public R operation(@RequestBody @Validated(Update.class) AlarmCentreDto dto){
        return alarmCentreService.operation(dto);
    }

    /**
     * 获取告警中心操作记录信息
     * @param
     * @return
     */
    @PostMapping("/operation/page")
    @ApiOperation(value = "获取告警中心操作记录信息")
    public R<Page<AlarmOperatingRecord>> getOperationPage(@RequestBody AlarmOperatingRecordPageDto dto ){
        Page page = new Page();
        page.setCurrent(dto.getCurrent());
        page.setSize(dto.getSize());
        page.setSearchCount(true);
        return alarmCentreService.getOperationPage(page, dto);
    }

    /**
     * 数据统计信息获取，按告警等级分布统计
     * @param
     * @return
     */
    @PostMapping("/dataList/alarmGrade")
    @ApiOperation(value = "数据统计信息获取，按告警等级分布统计")
    public R<List<StatusStatesVo>> dataListGrade(@RequestBody AlarmTimeDto dto){
        return alarmCentreService.dataListGrade(dto);
    }

    /**
     * 数据统计信息获取，按告警类型分布统计
     * @param
     * @return
     */
    @PostMapping("/dataList/alarmType")
    @ApiOperation(value = "数据统计信息获取，按告警类型分布统计")
    public R<List<TypeStatesVo>> dataListType(@RequestBody AlarmTimeDto dto){
        return alarmCentreService.dataListType(dto);
    }

    /**
     * 获取告警信息详情
     * @param
     * @return
     */
    @GetMapping("/detail/{alarmId}")
    @ApiOperation(value = "获取告警信息详情")
    public R<AlarmCentre> getAlarmDetail(@PathVariable(value = "alarmId") Long alarmId){
        return alarmCentreService.getAlarmDetail(alarmId);
    }

}
